package com.suray.basic.wcs.plc.pojo.oper.single.lifter;

import com.suray.basic.wcs.plc.core.PlcOffset;
import com.suray.basic.wcs.plc.enums.Location;
import com.suray.basic.wcs.plc.enums.PlcDeviceType;
import com.suray.basic.wcs.plc.pojo.DeviceBase;
import com.suray.basic.wcs.utils.Coord;

public class LifterStationOper extends DeviceBase {
    /**
     * 光电（远）
     */
    private static final PlcOffset REMOTE_SIGNAL = new PlcOffset(0, 0);

    /**
     * 光电（近）
     */
    private static final PlcOffset NEAR_SIGNAL = new PlcOffset(0, 1);

    /**
     * 光电（边缘）
     */
    private static final PlcOffset MARGIN_SIGNAL = new PlcOffset(0, 2);

    /**
     * 运行中
     */
    private static final PlcOffset RUNNING = new PlcOffset(0, 3);

    /**
     * 故障中
     */
    private static final PlcOffset ERROR = new PlcOffset(0, 4);

    /**
     * 急停中
     */
    private static final PlcOffset EMERGENCY_STOP = new PlcOffset(0, 5);

    /**
     * 手动中
     */
    private static final PlcOffset MANUAL_MODE = new PlcOffset(0, 6);

    /**
     * 自动中
     */
    private static final PlcOffset AUTO_MODE = new PlcOffset(0, 7);


    public LifterStationOper(PlcDeviceType plcDeviceType, int startNo, String deviceName, int deviceNo, Coord coord,
                             Location location, Coord lockLocation, long deviceId, Integer gridzMax,
                             Integer gridzRelative, int plcId) {
        super(plcDeviceType, startNo, deviceName, deviceNo, coord, location, lockLocation, deviceId, gridzMax,
                gridzRelative, plcId);
    }

    /**
     * 获取光电（远）
     * @return
     */
    public boolean isRemoteSignal() {
        return readPlc(REMOTE_SIGNAL) == 1;
    }

    /**
     * 获取光电（近）
     * @return
     */
    public boolean isNearSignal() {
        return readPlc(NEAR_SIGNAL) == 1;
    }

    /**
     * 获取光电（边缘）
     * @return
     */
    public boolean isMarginSignal() {
        return readPlc(MARGIN_SIGNAL) == 1;
    }

    /**
     * 运行中
     */
    public boolean isRunning() {
        return readPlc(RUNNING) == 1;
    }

    /**
     * 故障中
     */
    public boolean isError() {
        return readPlc(ERROR) == 1;
    }

    /**
     * 急停中
     */
    public boolean isEmergencyStop() {
        return readPlc(EMERGENCY_STOP) == 1;
    }

    /**
     * 手动中
     */
    public boolean isManualMode() {
        return readPlc(MANUAL_MODE) == 1;
    }

    /**
     * 自动中
     */
    public boolean isAutoMode() {
        return readPlc(AUTO_MODE) == 1;
    }
}
